<template>
  <div id="addBox">
      <textarea 
        @blur="checkContent" 
        v-model="sentance" 
        name="add" 
        id="addContent" 
        cols="100%" 
        rows="6" 
        placeholder="在此处添加语句，不能含有双引号"
        @click="hidden"
        ></textarea>
      <AddTag 
        v-bind:content="sentance" 
        v-bind:isTopSentance="iSentance" 
        id="addtag" type="1"></AddTag>
      <el-button style="margin-left:100px" type="warning" @click="reload">刷新页面</el-button>
  </div>
</template>
<script>
import AddTag from './component/AddTag'
export default {
  components:{
    AddTag
  },
  data(){
    return {
      sentance:'', //语句
      iSentance:false, //是否有语句
    }
  },
  watch:{
    sentance:val=>{
      this.sentance = val
    }
  },
  methods:{
    reload(){
      this.$router.go(0)
    },
    hidden:function(){
      this.displayList = false;
    },
    checkContent:function(){
      if(this.sentance.length >0){
        this.iSentance = true
      }
      if(this.sentance == 0){
        this.iSentance = false
      }
    }
  },
  created:function(){
    console.log('add.vue created:')
    // var params = new URLSearchParams();
    // params.append('name', sessionStorage.getItem('name'));
    // params.append('loginkey', sessionStorage.getItem('loginkey'));
    
    // this.$http.post('http://'+this.IP+'/api/getUserInfo.php',params)
    // .then((res)=>{
    //     if(res.data[0]['permission'] == 1111){
    //     this.$store.state.isAdmin = true;
    //     }else{
    //     this.$store.state.isAdmin = false;
    //     }
    // })
  }
}
</script>
<style scoped>
  #addBox{
    /* background-color: burlywood; */
    height: 100px;
    padding: 10px;
  }
  #addContent{
    resize: none;
    float: left;
  }
  #addtag{
    width: 30%;
    float: left;
    height: 100px;
  }
  #addTagBtn{
    margin-left: 2%;
    height: 50%;
    width: 5%
  }
</style>